package com.scu.hotelsystem.controller;

import com.scu.hotelsystem.pojo.GoodsCate;
import com.scu.hotelsystem.service.GoodsCateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
//@RequestMapping("/GoodsCate")
public class GoodsCateController {
    @Autowired
    GoodsCateService goodsCateService;

    @RequestMapping("goodsCate.save")
    public String save(GoodsCate goodsCate) throws Exception {
        goodsCateService.save(goodsCate);
        return "redirect:goodsCate.findAll";
    }

    @RequestMapping("/goodsCate.findAll")
    public ModelAndView findAll() throws Exception {
        ModelAndView mv=new ModelAndView();
        List<GoodsCate> gcs= goodsCateService.findAll();
        mv.addObject("productList",gcs);//may modify
        mv.setViewName("goodscatelist");//may modify
        return mv;
    }
}
